package com.elitel.frame.base.component;

import com.alibaba.fastjson.JSON;
//import com.elitel.common.redis.RedisDbIndex;
//import com.elitel.common.redis.service.RedisCacheService;
import com.elitel.frame.base.service.*;
import com.elitel.frame.main.entity.BaseQuerysql;
import com.elitel.frame.main.entity.ext.*;
import com.elitel.frame.main.entity.vo.FullTextSearchVo;
import com.elitel.frame.main.entity.vo.ZTreeDataModelVo;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author guoyanfei
 * @Description 缓存-数据库管理模块
 */
@Component("redisCacheDataBase")
public class RedisCacheDataBase {

    //    @Autowired
//    private RedisCacheService redisCacheService;
    @Autowired
    private CfgTableService cfgTableService;
    @Autowired
    private BaseFieldconfigService baseFieldconfigService;
    @Autowired
    private BaseFieldaddonsService baseFieldaddonsService;
    @Autowired
    private BaseQueryfieldService baseQueryfieldService;
    @Autowired
    private BaseShowfieldService baseShowfieldService;
    @Autowired
    private BaseQuerysqlService baseQuerysqlService;
    @Autowired
    private BaseEditconfigService baseEditconfigService;
    @Autowired
    private CfgExtsearchService cfgExtsearchService;
//    @Autowired
//    private RedisConnInfo redisConnInfo;

    /**
     * @return List<ZTreeDataModelVo>(ZTree数据格式集合)
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @Title: getTreeListRedisCache @Description: TODO(获取树形元数据表列表集合缓存服务)
     * @author guoyanfei
     * @see
     */
    @Cacheable(cacheNames = "DEFAULT", key = "'TREETABLE_metadata'")
    public List<ZTreeDataModelVo> getTreeListRedisCache() {
//    int rdi = RedisDbIndex.value;
//    List<ZTreeDataModelVo> zTreeDataModelVos = new ArrayList<ZTreeDataModelVo>();
//    if (redisConnInfo.checkConnReids()) {
//      String ztreestr = "";
//      String key = "TREETABLE_metadata";
//      if (redisCacheService.stringExists(key, rdi)) {
//        ztreestr = redisCacheService.getObject(key, rdi);
//        zTreeDataModelVos =
//            (List<ZTreeDataModelVo>) JSON.parseArray(ztreestr, ZTreeDataModelVo.class);
//      } else {
//        zTreeDataModelVos = cfgTableService.getAllList();
//        ztreestr = JSON.toJSONString(zTreeDataModelVos);
//        redisCacheService.saveObject(key, ztreestr, rdi);
//      }
//    } else {
//      zTreeDataModelVos = cfgTableService.getAllList();
//    }
        List<ZTreeDataModelVo> zTreeDataModelVos = cfgTableService.getAllList();
        return zTreeDataModelVos;
    }

    /**
     * @return List<ZTreeDataModelVo>(ZTree数据格式集合)
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @Title: getTreeListRedisCache @Description: TODO(获取树形元数据视图列表集合缓存服务)
     * @author guoyanfei
     * @see
     */
    @Cacheable(cacheNames = "DEFAULT", key = "'TREEVIEW_metadata'")
    public List<ZTreeDataModelVo> getTreeViewListRedisCache() {
//    int rdi = RedisDbIndex.value;
//    List<ZTreeDataModelVo> zTreeDataModelVos = new ArrayList<ZTreeDataModelVo>();
//
//    if (redisConnInfo.checkConnReids()) {
//      String ztreestr = "";
//      String key = "TREEVIEW_metadata";
//      if (redisCacheService.stringExists(key, rdi)) {
//        ztreestr = redisCacheService.getObject(key, rdi);
//        zTreeDataModelVos =
//            (List<ZTreeDataModelVo>) JSON.parseArray(ztreestr, ZTreeDataModelVo.class);
//      } else {
//        zTreeDataModelVos = cfgTableService.getViewList();
//        ztreestr = JSON.toJSONString(zTreeDataModelVos);
//        redisCacheService.saveObject(key, ztreestr, rdi);
//      }
//    } else {
//      zTreeDataModelVos = cfgTableService.getViewList();
//    }

        List<ZTreeDataModelVo> zTreeDataModelVos = cfgTableService.getViewList();
        return zTreeDataModelVos;
    }

    /**
     * @Title: getTreeListRedisCache @Description: TODO(树形元数据列表集合刷新缓存服务)
     * @author guoyanfei
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @see
     */
    @CachePut(value = CacheConfig.DEFAULT, key = "'TREETABLE_metadata'")
    public List<ZTreeDataModelVo> refreshTreelistRedisCache() {
//        if (!redisConnInfo.checkConnReids()) return;
//
//        int rdi = RedisDbIndex.value;
//        String key = "TREETABLE_metadata";
//        String ztreestr = JSON.toJSONString(cfgTableService.getAllList());
//        redisCacheService.saveObject(key, ztreestr, rdi);
        List<ZTreeDataModelVo> allList = cfgTableService.getAllList();
        return allList;
    }

    /**
     * @Title: refreshTreeViewRedisCache @Description: TODO(树形元数据视图列表集合刷新缓存服务)
     * @author guoyanfei
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @see
     */
    @CachePut(value = CacheConfig.DEFAULT, key = "'TREEVIEW_metadata'")
    public List<ZTreeDataModelVo> refreshTreeViewRedisCache() {
//        if (!redisConnInfo.checkConnReids()) return;
//
//        int rdi = RedisDbIndex.value;
//        String key = "TREEVIEW_metadata";
//        String ztreestr = JSON.toJSONString(cfgTableService.getViewList());
//        redisCacheService.saveObject(key, ztreestr, rdi);
        List<ZTreeDataModelVo> viewList = cfgTableService.getViewList();
        return viewList;
    }

    /**
     * @param dtconfigid(表标识)
     * @return List<BaseFieldconfigExt>
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @Title: getAllFieldConfigRedisCache @Description: TODO(通过表标识查询其关联表信息缓存服务)
     * @author guoyanfei
     * @see
     */
    @Cacheable(cacheNames = "DEFAULT", key = "'FIELDCONFIG_'+#dtconfigid+'_metadata'")
    public List<BaseFieldconfigExt> getAllFieldConfigRedisCache(String dtconfigid) {
//    int rdi = RedisDbIndex.value;
//    List<BaseFieldconfigExt> baseFieldconfigExts = new ArrayList<BaseFieldconfigExt>();
//
//    if (redisConnInfo.checkConnReids()) {
//      // 缓存数据
//      String key = "FIELDCONFIG_" + dtconfigid + "_metadata";
//      String strFieldconfig = "";
//      if (redisCacheService.stringExists(key, rdi)) {
//        strFieldconfig = redisCacheService.getObject(key, rdi);
//        baseFieldconfigExts = JSON.parseArray(strFieldconfig, BaseFieldconfigExt.class);
//        if (baseFieldconfigExts == null || baseFieldconfigExts.size() <= 0) {
//          redisCacheService.delObject(key, rdi);
//        }
//      } else {
//        baseFieldconfigExts = baseFieldconfigService.getAllFieldConfig(dtconfigid);
//        if (baseFieldconfigExts != null && baseFieldconfigExts.size() > 0) {
//          strFieldconfig = JSON.toJSONString(baseFieldconfigExts);
//          redisCacheService.saveObject(key, strFieldconfig, rdi);
//        }
//      }
//    } else {
//      baseFieldconfigExts = baseFieldconfigService.getAllFieldConfig(dtconfigid);
//    }

        List<BaseFieldconfigExt> baseFieldconfigExts = baseFieldconfigService.getAllFieldConfig(dtconfigid);
        return baseFieldconfigExts;
    }

    /**
     * @param dtconfigid(表标识)
     * @Title: refreshFieldConfigRedisCache @Description: TODO(关联表信息刷新缓存服务)
     * @author guoyanfei
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @see
     */
    @CachePut(cacheNames = CacheConfig.DEFAULT, key = "'FIELDCONFIG_'+#dtconfigid+'_metadata'")
    public List<BaseFieldconfigExt> refreshFieldConfigRedisCache(String dtconfigid) {
//        if (!redisConnInfo.checkConnReids()) return;
//        int rdi = RedisDbIndex.value;
//        String key = "FIELDCONFIG_" + dtconfigid + "_metadata";
//        String strFieldconfig = "";
//        List<BaseFieldconfigExt> baseFieldconfigExts =
//                baseFieldconfigService.getAllFieldConfig(dtconfigid);
//        if (baseFieldconfigExts != null && baseFieldconfigExts.size() > 0) {
//            strFieldconfig = JSON.toJSONString(baseFieldconfigExts);
//            redisCacheService.saveObject(key, strFieldconfig, rdi);
//        }
        List<BaseFieldconfigExt> baseFieldconfigExts =
                baseFieldconfigService.getAllFieldConfig(dtconfigid);
        return baseFieldconfigExts;
    }

    /**
     * @param dtconfigid(表标识)
     * @return List<BaseFieldconfigExt>集合
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @Title: selectExtendFieldaddonsListRedisCache @Description: TODO(通过表标识查询基本表附加属性信息缓存服务)
     * @author guoyanfei
     * @see
     */
    @Cacheable(cacheNames = "DEFAULT", key = "'FIELDADDONS_'+#dtconfigid+'_metadata'")
    public List<BaseFieldaddonsExt> selectExtendFieldaddonsListRedisCache(String dtconfigid) {
//        int rdi = RedisDbIndex.value;
//        List<BaseFieldaddonsExt> baseFieldaddonsExts = new ArrayList<BaseFieldaddonsExt>();
//        if (redisConnInfo.checkConnReids()) {
//            // 缓存数据
//            String key = "FIELDADDONS_" + dtconfigid + "_metadata";
//            String strFieldaddons = "";
//            if (redisCacheService.stringExists(key, rdi)) {
//                strFieldaddons = redisCacheService.getObject(key, rdi);
//                baseFieldaddonsExts = JSON.parseArray(strFieldaddons, BaseFieldaddonsExt.class);
//                if (baseFieldaddonsExts == null || baseFieldaddonsExts.size() <= 0) {
//                    redisCacheService.delObject(key, rdi);
//                }
//            } else {
//                baseFieldaddonsExts = baseFieldaddonsService.selectExtendFieldaddonsList(dtconfigid);
//                if (baseFieldaddonsExts != null && baseFieldaddonsExts.size() > 0) {
//                    strFieldaddons = JSON.toJSONString(baseFieldaddonsExts);
//                    redisCacheService.saveObject(key, strFieldaddons, rdi);
//                }
//            }
//        } else {
//            baseFieldaddonsExts = baseFieldaddonsService.selectExtendFieldaddonsList(dtconfigid);
//        }

        List<BaseFieldaddonsExt> baseFieldaddonsExts = baseFieldaddonsService.selectExtendFieldaddonsList(dtconfigid);
        return baseFieldaddonsExts;
    }

    /**
     * @param dtconfigid(表标识)
     * @return List<BaseFieldconfigExt>集合
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @Title: refreshFieldaddonsRedisCache @Description: TODO(基本表附加属性信息刷新缓存服务)
     * @author guoyanfei
     * @see
     */
    @CachePut(cacheNames = CacheConfig.DEFAULT, key = "'FIELDADDONS_'+#dtconfigid+'_metadata'")
    public List<BaseFieldaddonsExt> refreshFieldaddonsRedisCache(String dtconfigid) {
//        if (redisConnInfo.checkConnReids()) return;
//
//        int rdi = RedisDbIndex.value;
//        String key = "FIELDADDONS_" + dtconfigid + "_metadata";
//        String strFieldaddons = "";
//        List<BaseFieldaddonsExt> baseFieldaddonsExts =
//                baseFieldaddonsService.selectExtendFieldaddonsList(dtconfigid);
//        strFieldaddons = JSON.toJSONString(baseFieldaddonsExts);
//        redisCacheService.saveObject(key, strFieldaddons, rdi);
        List<BaseFieldaddonsExt> baseFieldaddonsExts =
                baseFieldaddonsService.selectExtendFieldaddonsList(dtconfigid);
        return baseFieldaddonsExts;
    }

    /**
     * @param serviceID(服务ID)
     * @param serviceType(服务类型)
     * @param grade(资源树服务层级)
     * @return List<BaseQueryfield>集合
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @Title: selectBaseQueryfieldRedisCache @Description: TODO(服务查询字段缓存服务)
     * @author guoyanfei
     * @see
     */
    @Cacheable(cacheNames = "DEFAULT", key = "'BASEQUERYFIELD_'+ #serviceID + '_' + #serviceType + '_' + #grade")
    public List<BaseQueryfieldExt> selectBaseQueryfieldRedisCache(
            String serviceID, String serviceType, String grade) {
//        int rdi = RedisDbIndex.value;
//        List<BaseQueryfieldExt> baseQueryfields = new ArrayList<BaseQueryfieldExt>();
//        if (redisConnInfo.checkConnReids()) {
//            // 缓存数据
//            String key = "BASEQUERYFIELD_" + serviceID + "_" + serviceType + "_" + grade;
//            String strBaseQueryfield = "";
//            if (redisCacheService.stringExists(key, rdi)) {
//                strBaseQueryfield = redisCacheService.getObject(key, rdi);
//                baseQueryfields = JSON.parseArray(strBaseQueryfield, BaseQueryfieldExt.class);
//                if (baseQueryfields == null || baseQueryfields.size() <= 0) {
//                    redisCacheService.delObject(key, rdi);
//                }
//            } else {
//                baseQueryfields =
//                        baseQueryfieldService.getQueryFieldListByServiceId(serviceID, serviceType, grade, "1");
//                if (baseQueryfields != null && baseQueryfields.size() > 0) {
//                    strBaseQueryfield = JSON.toJSONString(baseQueryfields);
//                    redisCacheService.saveObject(key, strBaseQueryfield, rdi);
//                }
//            }
//        } else {
//            baseQueryfields =
//                    baseQueryfieldService.getQueryFieldListByServiceId(serviceID, serviceType, grade, "1");
//        }

        return baseQueryfieldService.getQueryFieldListByServiceId(serviceID, serviceType, grade, 1);
    }

    /**
     * @param serviceID(服务ID)
     * @param serviceType(服务类型)
     * @param grade(资源树服务层级)
     * @Title: refreshBaseQueryfield @Description: TODO(刷新查询字段缓存服务)
     * @author guoyanfei
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @see
     */
    @CachePut(cacheNames = CacheConfig.DEFAULT, key = "'BASEQUERYFIELD_'+ #serviceID + '_' + #serviceType + '_' + #grade")
    public List<BaseQueryfieldExt> refreshBaseQueryfield(String serviceID, String serviceType, String grade) {
//        if (!redisConnInfo.checkConnReids()) return;
//
//        int rdi = RedisDbIndex.value;
//        if (grade == null) {
//            grade = "";
//        }
//        String key = "BASEQUERYFIELD_" + serviceID + "_" + serviceType + "_" + grade;
//        String strbaseQueryfields = "";
//        List<BaseQueryfieldExt> baseQueryfields =
//                baseQueryfieldService.getQueryFieldListByServiceId(serviceID, serviceType, grade, "1");
//        if (baseQueryfields != null) {
//            strbaseQueryfields = JSON.toJSONString(baseQueryfields);
//            redisCacheService.saveObject(key, strbaseQueryfields, rdi);
//        }
        return baseQueryfieldService.getQueryFieldListByServiceId(serviceID, serviceType, grade, 1);

    }

    /**
     * @param serviceID(服务ID)
     * @param serviceType(服务类型)
     * @param grade(资源树服务层级)
     * @return BaseQuerysql实体
     * @title selectBaseQuerysqlRedisCache
     * @descirption 服务查询列条件sql文缓存服务
     * @author guoyanfei
     * @date 2017/12/1
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @see
     */
    @Cacheable(cacheNames = "DEFAULT", key = "'BASEQUERYSQL_'+ #serviceID + '_' + #serviceType + '_' + #grade")
    public BaseQuerysql selectBaseQuerysqlRedisCache(
            String serviceID, String serviceType, String grade) {
//        int rdi = RedisDbIndex.value;
//        BaseQuerysql baseQuerysqls = new BaseQuerysql();
//        if (redisConnInfo.checkConnReids()) {
//            if (grade == null) {
//                grade = "";
//            }
//            // 缓存键
//            String key = "BASEQUERYSQL_" + serviceID + "_" + serviceType + "_" + grade;
//            String strBaseQuerysql = "";
//            if (redisCacheService.stringExists(key, rdi)) {
//                strBaseQuerysql = redisCacheService.getObject(key, rdi);
//                baseQuerysqls = JSON.parseObject(strBaseQuerysql, BaseQuerysql.class);
//                if (baseQuerysqls == null) {
//                    redisCacheService.delObject(key, rdi);
//                }
//            } else {
//                baseQuerysqls = baseQuerysqlService.getBaseQuerysql(serviceID, serviceType, grade);
//                if (baseQuerysqls != null) {
//                    strBaseQuerysql = JSON.toJSONString(baseQuerysqls);
//                    redisCacheService.saveObject(key, strBaseQuerysql, rdi);
//                }
//            }
//        } else {
//            baseQuerysqls = baseQuerysqlService.getBaseQuerysql(serviceID, serviceType, grade);
//        }
        BaseQuerysql baseQuerysqls = baseQuerysqlService.getBaseQuerysql(serviceID, serviceType, grade);
        return baseQuerysqls;
    }

    /**
     * @param serviceID(服务ID)
     * @param serviceType(服务类型)
     * @param grade(资源树服务层级)
     * @return BaseQuerysql实体
     * @title refreshBaseQuerysql
     * @descirption 刷新服务查询列条件sql文缓存服务
     * @author guoyanfei
     * @date 2017/12/1
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @see
     */
    @CachePut(cacheNames = CacheConfig.DEFAULT, key = "'BASEQUERYSQL_'+ #serviceID + '_' + #serviceType + '_' + #grade")
    public BaseQuerysql refreshBaseQuerysql(String serviceID, String serviceType, String grade) {
//        if (!redisConnInfo.checkConnReids()) return;
//
//        int rdi = RedisDbIndex.value;
//        // 缓存键
//        if (grade == null) {
//            grade = "";
//        }
//        String key = "BASEQUERYSQL_" + serviceID + "_" + serviceType + "_" + grade;
//        String strBaseQuerysql = "";
//        BaseQuerysql baseQuerysqls = baseQuerysqlService.getBaseQuerysql(serviceID, serviceType, grade);
//        if (baseQuerysqls != null) {
//            strBaseQuerysql = JSON.toJSONString(baseQuerysqls);
//            redisCacheService.saveObject(key, strBaseQuerysql, rdi);
//        }
        BaseQuerysql baseQuerysqls =
                baseQuerysqlService.getBaseQuerysql(serviceID, serviceType, grade);
        return baseQuerysqls;

    }

    /**
     * @param serviceID(服务ID)
     * @param serviceType(服务类型)
     * @param masterDetailId(主从表服务-从表ID)
     * @return List<BaseQueryfield>集合
     * @throws
     * @Title: selectBaseShowfieldRedisCache @Description: TODO(服务显示字段缓存服务)
     * @author guoyanfei
     * @date 2017/11/17
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @see
     */
    @Cacheable(cacheNames = "DEFAULT", key = "'BASESHOWFIELD_'+ #serviceID + '_' + #masterDetailId + '_' + #serviceType")
    public List<BaseShowfieldExt> selectBaseShowfieldRedisCache(
            String serviceID, String serviceType, String masterDetailId) {
//        int rdi = RedisDbIndex.value;
//        List<BaseShowfieldExt> baseShowfieldExts = new ArrayList<BaseShowfieldExt>();
//        if (redisConnInfo.checkConnReids()) {
//
//            // 缓存数据
//            String key = "BASESHOWFIELD_" + serviceID + "_" + masterDetailId + "_" + serviceType;
//            String strBaseShowfield = "";
//            if (redisCacheService.stringExists(key, rdi)) {
//                strBaseShowfield = redisCacheService.getObject(key, rdi);
//                baseShowfieldExts = JSON.parseArray(strBaseShowfield, BaseShowfieldExt.class);
//                if (baseShowfieldExts == null || baseShowfieldExts.size() <= 0) {
//                    redisCacheService.delObject(key, rdi);
//                }
//            } else {
//                baseShowfieldExts =
//                        baseShowfieldService.getShowfieldList(serviceID, serviceType, masterDetailId);
//                if (baseShowfieldExts != null && baseShowfieldExts.size() > 0) {
//                    strBaseShowfield = JSON.toJSONString(baseShowfieldExts);
//                    redisCacheService.saveObject(key, strBaseShowfield, rdi);
//                }
//            }
//        }

        List<BaseShowfieldExt> baseShowfieldExts = baseShowfieldService.getShowfieldList(serviceID, serviceType, masterDetailId);

        return baseShowfieldExts;
    }

    /**
     * @param serviceID(服务ID)
     * @param serviceType(服务类型)
     * @param masterDetailId(主从表服务-从表服务ID)
     * @throws
     * @Title: refreshBaseShowfield @Description: TODO(刷新显示字段缓存服务)
     * @author guoyanfei
     * @date 2017/11/17
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @see
     */
    @CachePut(cacheNames = CacheConfig.DEFAULT, key = "'BASESHOWFIELD_'+ #serviceID + '_' + #masterDetailId + '_' + #serviceType")
    public List<BaseShowfieldExt> refreshBaseShowfield(String serviceID, String serviceType, String masterDetailId) {
//        if (!redisConnInfo.checkConnReids()) return;
//
//        int rdi = RedisDbIndex.value;
//        String key = "BASESHOWFIELD_" + serviceID + "_" + masterDetailId + "_" + serviceType;
//        String strbaseShowfields = "";
//        List<BaseShowfieldExt> baseShowfieldExts =
//                baseShowfieldService.getShowfieldList(serviceID, serviceType, masterDetailId);
//        if (baseShowfieldExts != null && baseShowfieldExts.size() > 0) {
//            strbaseShowfields = JSON.toJSONString(baseShowfieldExts);
//            redisCacheService.saveObject(key, strbaseShowfields, rdi);
//        }
        List<BaseShowfieldExt> baseShowfieldExts =
                baseShowfieldService.getShowfieldList(serviceID, serviceType, masterDetailId);
        return baseShowfieldExts;

    }

    /**
     * @param serviceID(服务ID)
     * @return BaseEditconfigExt实体List集合
     * @Description: TODO(单表编辑服务校验列查询RedisCache)
     * @author guoyanfei
     * @date 2018/01/08
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @see
     */
    @Cacheable(cacheNames = "DEFAULT", key = "'BASEEDITCONFIG_'+ #serviceID")
    public List<BaseEditconfigExt> selectBaseEditconfigRedisCache(String serviceID) {
//        int rdi = RedisDbIndex.value;
//        List<BaseEditconfigExt> baseEditconfigExts = new ArrayList<BaseEditconfigExt>();
//        if (redisConnInfo.checkConnReids()) {
//            String key = "BASEEDITCONFIG_" + serviceID;
//            String strBaseEditconfig = "";
//            if (redisCacheService.stringExists(key, rdi)) {
//                strBaseEditconfig = redisCacheService.getObject(key, rdi);
//                baseEditconfigExts =
//                        (List<BaseEditconfigExt>) JSON.parseArray(strBaseEditconfig, BaseEditconfigExt.class);
//            } else {
//                baseEditconfigExts = baseEditconfigService.getAllBaseEditByServiceId(serviceID);
//                if (baseEditconfigExts != null && baseEditconfigExts.size() > 0) {
//                    strBaseEditconfig = JSON.toJSONString(baseEditconfigExts);
//                    redisCacheService.saveObject(key, strBaseEditconfig, rdi);
//                }
//            }
//        } else {
//            baseEditconfigExts = baseEditconfigService.getAllBaseEditByServiceId(serviceID);
//        }

        List<BaseEditconfigExt> baseEditconfigExts = baseEditconfigService.getAllBaseEditByServiceId(serviceID);
        return baseEditconfigExts;
    }

    /**
     * @param serviceID(服务ID)
     * @Description:TODO(刷新单表编辑服务校验列Redis缓存)
     * @author guoyanfei
     * @date 2018/01/08
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @see
     */
    @CachePut(cacheNames = CacheConfig.DEFAULT, key = "'BASEEDITCONFIG_'+ #serviceID")
    public List<BaseEditconfigExt> refreshBaseEditconfigRedisCache(String serviceID) {
//        if (!redisConnInfo.checkConnReids()) return;
//
//        int rdi = RedisDbIndex.value;
//        String key = "BASEEDITCONFIG_" + serviceID;
//        List<BaseEditconfigExt> baseEditconfigExts = new ArrayList<BaseEditconfigExt>();
//        baseEditconfigExts = baseEditconfigService.getAllBaseEditByServiceId(serviceID);
//        if (baseEditconfigExts != null && baseEditconfigExts.size() > 0) {
//            String strBaseEditconfigExts = JSON.toJSONString(baseEditconfigExts);
//            redisCacheService.saveObject(key, strBaseEditconfigExts, rdi);
//        } else {
//            redisCacheService.delObject(key, rdi);
//        }
        List<BaseEditconfigExt> baseEditconfigExts = baseEditconfigService.getAllBaseEditByServiceId(serviceID);
        return baseEditconfigExts;
    }

    /**
     * show 查询全文检索配置信息Redis created on 2018/03/28
     *
     * @param serviceID 服务ID
     * @return FullTextSearchVo实体list集合
     * @author guoyanfei
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @see
     */
    @Cacheable(cacheNames = "DEFAULT", key = "'SEARCH_'+ #serviceID")
    public List<FullTextSearchVo> selectFullTextSearchRedisCache(String serviceID) {
//        int rdi = RedisDbIndex.value;
//        List<FullTextSearchVo> fullTextSearchVos = new ArrayList<>();
//        if (redisConnInfo.checkConnReids()) {
//            String key = "SEARCH_" + serviceID;
//            String strfullTextSearchVo = "";
//            if (redisCacheService.stringExists(key, rdi)) {
//                strfullTextSearchVo = redisCacheService.getObject(key, rdi);
//                fullTextSearchVos =
//                        (List<FullTextSearchVo>) JSON.parseArray(strfullTextSearchVo, FullTextSearchVo.class);
//            } else {
//                fullTextSearchVos = cfgExtsearchService.getBasesearchInfoByserviceId(serviceID);
//                if (fullTextSearchVos != null && fullTextSearchVos.size() > 0) {
//                    strfullTextSearchVo = JSON.toJSONString(fullTextSearchVos);
//                    redisCacheService.saveObject(key, strfullTextSearchVo, rdi);
//                }
//            }
//
//        } else {
//            fullTextSearchVos = cfgExtsearchService.getBasesearchInfoByserviceId(serviceID);
//        }

        List<FullTextSearchVo> fullTextSearchVos =
                cfgExtsearchService.getBasesearchInfoByserviceId(serviceID);

        return fullTextSearchVos;
    }

    /**
     * show 刷新全文检索配置信息redis缓存 created on 2018/03/28
     *
     * @param serviceID 服务ID
     * @author guoyanfei
     * <p>modify by guoyanfei on 2019/07/16 新增验证redis连通性
     * @see
     */
    @CachePut(cacheNames = CacheConfig.DEFAULT, key = "'SEARCH_'+ #serviceID")
    public List<FullTextSearchVo> refreshFullTextSearchVoRedisCache(String serviceID) {
//        if (!redisConnInfo.checkConnReids()) return;
//
//        int rdi = RedisDbIndex.value;
//        List<FullTextSearchVo> fullTextSearchVos = new ArrayList<>();
//        String key = "SEARCH_" + serviceID;
//        fullTextSearchVos = cfgExtsearchService.getBasesearchInfoByserviceId(serviceID);
//        if (fullTextSearchVos != null && fullTextSearchVos.size() > 0) {
//            String strFullTextSearchVos = JSON.toJSONString(fullTextSearchVos);
//            redisCacheService.saveObject(key, strFullTextSearchVos, rdi);
//        } else {
//            redisCacheService.delObject(key, rdi);
//        }
        List<FullTextSearchVo> fullTextSearchVos = cfgExtsearchService.getBasesearchInfoByserviceId(serviceID);
        return fullTextSearchVos;
    }
}
